import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    rightList: JSON.parse(sessionStorage.getItem('rightList')) || '[]', // 菜单列表
    username: JSON.parse(sessionStorage.getItem('username')) || '' // 用户名称
  },
  mutations: {
    setUserName (state, data) {
      state.username = data
      sessionStorage.setItem('username', JSON.stringify(data))
    },
    setRightList (state, data) {
      state.rightList = data
      sessionStorage.setItem('rightList', JSON.stringify(data))
    }
  },
  actions: {
  },
  modules: {
  }
})
